package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PurchaseBookList;
import com.pgybook.db.entity.domain.PurchaseBookListEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PurchaseBookListMapper {
    int countByExample(PurchaseBookListEx example);

    int deleteByExample(PurchaseBookListEx example);

    @Delete({
            "delete from purchasebooklist",
            "where PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long purchasebookid);

    @Insert({
            "insert into purchasebooklist (ISBN, AUTHOR1, ",
            "PUBTIME, PAGECNT, PAPERSIZE, ",
            "PACKING, PRICE, ",
            "WEIGHT, LANGUAGE, ",
            "STATUS, BUYNEWBOOK, ",
            "REWARDCOIN, BOOKNUM, ",
            "REASON, MEMO, CRTTIME, ",
            "UPDTIME, CRTSTAFF, ",
            "UPDSTAFF, NAME, ",
            "INSTANCEID, STAFFID, ",
            "CONTENT)",
            "values (#{isbn,jdbcType=VARCHAR}, #{author1,jdbcType=INTEGER}, ",
            "#{pubtime,jdbcType=DATE}, #{pagecnt,jdbcType=INTEGER}, #{papersize,jdbcType=VARCHAR}, ",
            "#{packing,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, ",
            "#{weight,jdbcType=INTEGER}, #{language,jdbcType=INTEGER}, ",
            "#{status,jdbcType=INTEGER}, #{buynewbook,jdbcType=INTEGER}, ",
            "#{rewardcoin,jdbcType=INTEGER}, #{booknum,jdbcType=INTEGER}, ",
            "#{reason,jdbcType=INTEGER}, #{memo,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{updtime,jdbcType=TIMESTAMP}, #{crtstaff,jdbcType=INTEGER}, ",
            "#{updstaff,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
            "#{instanceid,jdbcType=BIGINT}, #{staffid,jdbcType=INTEGER}, ",
            "#{content,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "purchasebookid", before = false, resultType = Long.class)
    int insert(PurchaseBookList record);

    int insertSelective(PurchaseBookList record);

    List<PurchaseBookList> selectByExampleWithBLOBs(PurchaseBookListEx example);

    List<PurchaseBookList> selectByExample(PurchaseBookListEx example);

    @Select({
            "select",
            "PURCHASEBOOKID, ISBN, AUTHOR1, PUBTIME, PAGECNT, PAPERSIZE, PACKING, PRICE, ",
            "WEIGHT, LANGUAGE, STATUS, BUYNEWBOOK, REWARDCOIN, BOOKNUM, REASON, MEMO, CRTTIME, ",
            "UPDTIME, CRTSTAFF, UPDSTAFF, NAME, INSTANCEID, STAFFID, CONTENT",
            "from purchasebooklist",
            "where PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT}"
    })
    @ResultMap("ResultMapWithBLOBs")
    PurchaseBookList selectByPrimaryKey(Long purchasebookid);

    int updateByExampleSelective(@Param("record") PurchaseBookList record, @Param("example") PurchaseBookListEx example);

    int updateByExampleWithBLOBs(@Param("record") PurchaseBookList record, @Param("example") PurchaseBookListEx example);

    int updateByExample(@Param("record") PurchaseBookList record, @Param("example") PurchaseBookListEx example);

    int updateByPrimaryKeySelective(PurchaseBookList record);

    @Update({
            "update purchasebooklist",
            "set ISBN = #{isbn,jdbcType=VARCHAR},",
            "AUTHOR1 = #{author1,jdbcType=INTEGER},",
            "PUBTIME = #{pubtime,jdbcType=DATE},",
            "PAGECNT = #{pagecnt,jdbcType=INTEGER},",
            "PAPERSIZE = #{papersize,jdbcType=VARCHAR},",
            "PACKING = #{packing,jdbcType=VARCHAR},",
            "PRICE = #{price,jdbcType=DECIMAL},",
            "WEIGHT = #{weight,jdbcType=INTEGER},",
            "LANGUAGE = #{language,jdbcType=INTEGER},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "BUYNEWBOOK = #{buynewbook,jdbcType=INTEGER},",
            "REWARDCOIN = #{rewardcoin,jdbcType=INTEGER},",
            "BOOKNUM = #{booknum,jdbcType=INTEGER},",
            "REASON = #{reason,jdbcType=INTEGER},",
            "MEMO = #{memo,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER},",
            "NAME = #{name,jdbcType=VARCHAR},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "STAFFID = #{staffid,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=LONGVARCHAR}",
            "where PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(PurchaseBookList record);

    @Update({
            "update purchasebooklist",
            "set ISBN = #{isbn,jdbcType=VARCHAR},",
            "AUTHOR1 = #{author1,jdbcType=INTEGER},",
            "PUBTIME = #{pubtime,jdbcType=DATE},",
            "PAGECNT = #{pagecnt,jdbcType=INTEGER},",
            "PAPERSIZE = #{papersize,jdbcType=VARCHAR},",
            "PACKING = #{packing,jdbcType=VARCHAR},",
            "PRICE = #{price,jdbcType=DECIMAL},",
            "WEIGHT = #{weight,jdbcType=INTEGER},",
            "LANGUAGE = #{language,jdbcType=INTEGER},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "BUYNEWBOOK = #{buynewbook,jdbcType=INTEGER},",
            "REWARDCOIN = #{rewardcoin,jdbcType=INTEGER},",
            "BOOKNUM = #{booknum,jdbcType=INTEGER},",
            "REASON = #{reason,jdbcType=INTEGER},",
            "MEMO = #{memo,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER},",
            "NAME = #{name,jdbcType=VARCHAR},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "STAFFID = #{staffid,jdbcType=INTEGER}",
            "where PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PurchaseBookList record);
}
